<?php

require_once 'includes/constants.php';

$customer_name = $_POST['customer_name'];
$customer_phone = $_POST['customer_phone'];
$shipping_address = $_POST['shipping_address'];

$my_post = array(
    'post_title' => 'Order ' . date('Y-m-d H:i:s'),
    'post_type' => ORDER_POST_TYPE,
    'post_date' => date('Y-m-d H:i:s')
);

$post_id = wp_insert_post($my_post, false);
if ($post_id != 0) {
    update_post_meta($post_id, 'customer_name', $customer_name);
    update_post_meta($post_id, 'customer_phone', $customer_phone);
    update_post_meta($post_id, 'shipping_address', $shipping_address);
    echo 'Successful!';
}

$shopping_cart = serialize(Buffalo_Cart::get_products());
update_post_meta($post_id, 'buffalo-products', $shopping_cart);
?>
